﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Reflection;

namespace RM.Common
{
    public class PageBase:System.Web.UI.Page
    {
        #region static readonly
        private static readonly string SK_ONLINE_UPDATE_TIME = "OnlineUpdateTime";
        private static readonly string CHECK_POWER_FAIL_PAGE_MESSAGE = "您无权访问此页面！";
        private static readonly string CHECK_POWER_FAIL_ACTION_MESSAGE = "您无权进行此操作！";
        #endregion

        
        protected void CheckPowerFailWithPage()
        {
            Response.Write(CHECK_POWER_FAIL_PAGE_MESSAGE);
            Response.End();
        }
        protected void CheckPowerFailWithButton(System.Web.UI.WebControls.Button btn)
        {
            btn.Enabled = false;
            btn.ToolTip = CHECK_POWER_FAIL_ACTION_MESSAGE;
        }
        protected void CheckPowerFailWithLinkButton(System.Web.UI.WebControls.LinkButton linkBtn)
        {
            linkBtn.Enabled = false;
            linkBtn.ToolTip = CHECK_POWER_FAIL_ACTION_MESSAGE;
        }
        protected string GetIdentityRoleIDs()
        {
            FormsAuthenticationTicket ticket = ((FormsIdentity)User.Identity).Ticket;
            return ticket.UserData;
        }
        protected void CheckPowerFailWithHtmlControl(System.Web.UI.HtmlControls.HtmlGenericControl html)
        {
           html.Visible = false;
        }

        public string GetProductVersion()
        {
            Version v = Assembly.GetCallingAssembly().GetName().Version;
            return String.Format("{0}.{1}.{2}.{3}", v.Major, v.Minor,v.Build,v.Revision);
        }


    }
}